<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2016/2/24 0024
  Time: 11:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>修改密码</title>
    <style>
        .error{color:#cb1448;}
    </style>
    <script type="text/javascript">
            function checkLength() {
                var userPwd = document.getElementById("userPwd"); //获取密码框值
                var password = document.getElementById("password"); //获取密码框值
                if (password.value == null || password.value == "") {
                    $("#password-label > .error").remove();
                    $("#userPwd-label > .error").remove();
                    $("#password-label").append('<span class="error">请输入原密码</span>');
                    return false;
                }
                if (userPwd.value==null || userPwd.value==""){
                    $("#password-label > .error").remove();
                    $("#userPwd-label > .error").remove();
                    $("#userPwd-label").append('<span class="error">请输入新密码</span>');
                    return false;
                }else if (userPwd.value.length < 6) {
                    $("#password-label > .error").remove();
                    $("#userPwd-label > .error").remove();
                    $("#userPwd-label").append('<span class="error">前输入大于6位数以上密码</span>');
                    return false;
                }
                document.getElementById("phoneForm").submit();
        }
    </script>
</head>
<body>
<article class="viewports">
    <form:form  method="post" id="phoneForm" action="${ctx}/user/update_password">
    <ul class="plr20 lh1-5 mt30">
        <li class="ptb20">
            <div class="c8">
                <div class="odr2 plr10 mt20 b-ffffff" >
                    <input class="i_text" id="password" name="password" type="password" placeholder="原密码">
                </div>
                <span id="password-label"></span>
                <c:if test="${errorType==1}">
                    <span class="error" >${error}</span>
                </c:if>
                <div class="odr2 plr10 mt20 b-ffffff" >
                    <input class="i_text" id="userPwd" name="userPwd" type="password"  placeholder="设置新密码">
                </div>
                <span id="userPwd-label"></span>
                <c:if test="${errorType==2}">
                    <span class="error" >${error}</span>
                </c:if>
            </div>
        </li>
    </ul>
    <div class="tac ptb30"><button class="i_btn b-2db22d cf r5 lh2 plr120" type="button" onclick = "checkLength();" >保存</button></div>
    </form:form>
</article>
</body>
</html>